<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function(){
	
	$("#sub").click(function(){
		$("#box tr:not(#tr1)").remove();
		var id=$("#id1").val();
		var risk=$("#risk").val();
		$.ajax({
			url : "ListId",
			method : "post",
			data : {id : id,risk : risk},
			dataType : "json",
			success : function(data) {
				if (data!=null) {
					for(var i=0;i<data.length;i++){
						$("#box").append("<tr><td>"+data[i].id+"</td>"+"<td>R"+data[i].risk+"</td>"+"<td>"
								+data[i].income+"</td>"+"<td>"+data[i].saleStarting+"</td>"
								+"<td>"+data[i].saleEnd+"</td>"+"<td>"+data[i].end+"</td></tr>");
				}
				}
			}
		});
	});
	
});
</script>
</head>
<body>
<c:if test="${empty requestScope.pro }">
	<script type="text/javascript">
		location.href="indexList";
	</script>
</c:if>

<form action="#" method="post">
	<p>
	<span>产品代码<input type="text" name="id" id="id1"></span>
	<span>
	风险评级
	<select name="risk" id="risk">
		<option value="0" >请选择</option>
		<option value="1">R1</option>
		<option value="2">R2</option>
		<option value="3">R3</option>
	</select>
	</span>
	<input type="button" value="查询" id="sub">&nbsp;&nbsp;&nbsp;
	<a href="add.jsp">新增理财信息</a>
	</p>
</form>
<table border="1" id="box">
	<tr id="tr1">
		<th>产品代码</th>
		<th>风险评级</th>
		<th>预期收益</th>
		<th>发售起始日</th>
		<th>发售截止日</th>
		<th>产品到期日</th>
	</tr>
	<c:forEach var="pro" items="${requestScope.pro }">
	<tr>
		<td id="td1">${pro.id }</td>
		<td id="td2">R${pro.risk }</td>
		<td id="td3">${pro.income }</td>
		<td id="td4">${pro.saleStarting }</td>
		<td id="td5">${pro.saleEnd }</td>
		<td id="td6">${pro.end }</td>
	</tr>
	</c:forEach>
</table>
</body>
</html>